package DimondExercises;

import javax.xml.bind.SchemaOutputResolver;
import java.util.Scanner;

/**
 * Created by venus on 11/09/14.
 */
public class IsoscelesTriangle {

    public static void main(String[] args) {

        System.out.println("How many asterisks would you like? (Please enter a number) ");
        int numberOfRows;

        //Read number of rows
        Scanner input = new Scanner(System.in);

        //Check if the number is valid
        try {
            numberOfRows = input.nextInt();
        } catch (Exception e) {
            System.out.println("Wrong number. Please try again.");
            return;
        }

        //printout the diamond
        int spaceCount = numberOfRows -1;
        int starCount = 1;

        for (int rowCounts = 0; rowCounts < numberOfRows; rowCounts++)
        {
            for ( int k = 0; k < spaceCount; k++) {
                System.out.print(" ");
            }

            for (int j = 0; j < starCount; j++) {
                System.out.print("*");
            }
            starCount += 2;
            spaceCount--;
            System.out.println();
        }
    }
}